package kuang;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
 * @author cyt
 * @create 2020-03-06 21:57
 */
public class DownloaderPicture implements Runnable {

    public static void main(String[] args) {
        DownloaderPicture picture = new DownloaderPicture();
        new Thread(picture, "A").start();
        //new Thread(picture, "B").start();
        //new Thread(picture, "C").start();
    }

    // private String url = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1583553668183&di=e63b1dd525905bde37fef9da3e5a09cc&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F36%2F48%2F19300001357258133412489354717.jpg";
    private String url = "http://www.jq22.com/demo/jquery-publicity20151104/zyupload/skins/images/finish.png";

    void down(String name) throws IOException {
        FileUtils.copyURLToFile(new URL(url), new File(name));
    }

    @Override
    public void run() {
        for (int i = 0; i < 1; i++) {
            try {
                down("finish.png");

                System.out.println("name :" + i + Thread.currentThread().getName());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
